<template>
  <div>
    <el-table
      :data="laboratoryList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="实验室编号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="实验室名称">
      </el-table-column>
      <el-table-column
        prop="description"
        label="实验室描述">
      </el-table-column>

      <el-table-column
        prop="capacity"
        label="实验室容量">
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button @click="deleteById(scope.row.id)">删除</el-button>
          <el-button @click="updateById(scope.row.id)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
    <router-view/>
  </div>
</template>

<script>
export default {
  name: "LaboratoryList",
  data(){
    return{
      laboratoryList:[]
    }
  },
  methods:{
    selectAll(){
      this.axios.get("/laboratory/selectAll").then((resp)=>{
        if(resp.data.status=="success"){
          this.laboratoryList=resp.data.list
        }
      })
    },
    deleteById(id){
      this.$confirm("是否确认删除","删除提示").then(()=> {
        this.axios.delete("/laboratory/deleteById/" + id).then((resp) => {
          if (resp.data.status == "success") {
            this.$message.success("删除成功！");
            this.selectAll()
          }
        })
      })
    }
  },
  created() {
    this.selectAll()
  }
}
</script>

<style scoped>

</style>
